package com.wrial.utils;
/*
 * @Author  Wrial
 * @Date Created in 9:37 2020/4/1
 * @Description 模拟死锁
 */

import java.util.concurrent.locks.ReentrantLock;

public class DeadLock {


    public static void main(String[] args) throws InterruptedException {


        Object lock1 = new Object();
        Object lock2 = new Object();
        Thread s1 = new Thread(()->{
            synchronized (lock1){
                System.out.println("getLock1");
                synchronized (lock2){
                    System.out.println("getLock2");
                }
            }
        });
        Thread s2 = new Thread(()->{
            synchronized (lock2){
                System.out.println("s2 getLock2");
                synchronized (lock1){
                    System.out.println("s2 getlock1");
                }
            }
        });
        s1.start();
        s2.start();

    }


}
